<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>分类: 技术教程 | 小小程序员</title><meta name="author" content="十一星野"><meta name="copyright" content="十一星野"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="最近发现很多朋友问我权限管理功能相关的问题，这里整理了下问的比较多的问题，统一答复下！  #👍 相关视频教程 权限模块数据库表解析open in new window 权限模块接口设计与实现_上篇open in new window 权限模块接口设计与实现_下篇open in new window  #mall项目中的权限管理功能是如何实现的？之前写过几篇文章，包括了权限管理功能介绍、后端实现">
<meta property="og:type" content="article">
<meta property="og:title" content="搞定Mall项目中的权限管理功能，弄懂这些问题就妥了！">
<meta property="og:url" content="https://ko25891wan.gitlab.io/2024/01/bdace4359249.html">
<meta property="og:site_name" content="小小程序员">
<meta property="og:description" content="最近发现很多朋友问我权限管理功能相关的问题，这里整理了下问的比较多的问题，统一答复下！  #👍 相关视频教程 权限模块数据库表解析open in new window 权限模块接口设计与实现_上篇open in new window 权限模块接口设计与实现_下篇open in new window  #mall项目中的权限管理功能是如何实现的？之前写过几篇文章，包括了权限管理功能介绍、后端实现">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png">
<meta property="article:published_time" content="2024-01-21T09:27:24.000Z">
<meta property="article:modified_time" content="2024-02-02T15:01:16.080Z">
<meta property="article:author" content="十一星野">
<meta property="article:tag" content="宅男,热血">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://ko25891wan.gitlab.io/2024/01/bdace4359249.html"><link rel="preconnect" href="//fastly.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":1,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.staticfile.org/egjs-infinitegrid/4.11.0/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '分类: 技术教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-02-02 23:01:16'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="小小程序员"><span class="site-name">小小程序员</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">搞定Mall项目中的权限管理功能，弄懂这些问题就妥了！</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-21T09:27:24.000Z" title="发表于 2024-01-21 17:27:24">2024-01-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-02-02T15:01:16.080Z" title="更新于 2024-02-02 23:01:16">2024-02-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/">技术教程</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/">mall</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/%E6%8A%80%E6%9C%AF%E8%A6%81%E7%82%B9%E7%AF%87/">技术要点篇</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.3k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="搞定Mall项目中的权限管理功能，弄懂这些问题就妥了！"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><blockquote>
<p>最近发现很多朋友问我权限管理功能相关的问题，这里整理了下问的比较多的问题，统一答复下！</p>
</blockquote>
<h2 id="👍-相关视频教程"><a href="#👍-相关视频教程" class="headerlink" title="#👍 相关视频教程"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#%F0%9F%91%8D-%E7%9B%B8%E5%85%B3%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B">#</a>👍 相关视频教程</h2><ul>
<li><a target="_blank" rel="noopener" href="https://t.zsxq.com/0eyQIie0j">权限模块数据库表解析open in new window</a></li>
<li><a target="_blank" rel="noopener" href="https://t.zsxq.com/0e8QESTEU">权限模块接口设计与实现_上篇open in new window</a></li>
<li><a target="_blank" rel="noopener" href="https://t.zsxq.com/0envLA5Wv">权限模块接口设计与实现_下篇open in new window</a></li>
</ul>
<h3 id="mall项目中的权限管理功能是如何实现的？"><a href="#mall项目中的权限管理功能是如何实现的？" class="headerlink" title="#mall项目中的权限管理功能是如何实现的？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD%E6%98%AF%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%9A%84">#</a>mall项目中的权限管理功能是如何实现的？</h3><p>之前写过几篇文章，包括了权限管理功能介绍、后端实现和前端实现，看一下基本就清楚了！</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/database/mall_permission.html">《大家心心念念的权限管理功能，这次安排上了！》</a></li>
<li><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/permission_back.html">《手把手教你搞定权限管理，结合Spring Security实现接口的动态权限控制！》</a></li>
<li><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/permission_front.html">《手把手教你搞定权限管理，结合Vue实现菜单的动态权限控制！》</a></li>
</ul>
<h3 id="ums-permission表还在使用么？"><a href="#ums-permission表还在使用么？" class="headerlink" title="#ums_permission表还在使用么？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#ums-permission%E8%A1%A8%E8%BF%98%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B9%88">#</a><code>ums_permission</code>表还在使用么？</h3><p><code>ums_permission</code>表已经不再使用了，不再使用的表还包括<code>ums_admin_permission_relation</code>和<code>ums_role_permission_relation</code>表，最新版已经移除了相关使用代码。</p>
<h3 id="mall项目升级代码后ums-resource表找不到？"><a href="#mall项目升级代码后ums-resource表找不到？" class="headerlink" title="#mall项目升级代码后ums_resource表找不到？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall%E9%A1%B9%E7%9B%AE%E5%8D%87%E7%BA%A7%E4%BB%A3%E7%A0%81%E5%90%8Eums-resource%E8%A1%A8%E6%89%BE%E4%B8%8D%E5%88%B0">#</a>mall项目升级代码后<code>ums_resource</code>表找不到？</h3><p>升级代码以后需要同时导入最新版本的SQL脚本，否则会找不到新创建的表，SQL脚本在项目的<code>document\sql</code>文件夹下面。</p>
<h3 id="只实现了管理后台的权限，移动端权限如何处理的？"><a href="#只实现了管理后台的权限，移动端权限如何处理的？" class="headerlink" title="#只实现了管理后台的权限，移动端权限如何处理的？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#%E5%8F%AA%E5%AE%9E%E7%8E%B0%E4%BA%86%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E7%9A%84%E6%9D%83%E9%99%90-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E6%9D%83%E9%99%90%E5%A6%82%E4%BD%95%E5%A4%84%E7%90%86%E7%9A%84">#</a>只实现了管理后台的权限，移动端权限如何处理的？</h3><p>移动端只实现了登录认证，暂时不做权限处理。</p>
<h3 id="在管理后台添加了一个菜单，为什么前端没有显示？"><a href="#在管理后台添加了一个菜单，为什么前端没有显示？" class="headerlink" title="#在管理后台添加了一个菜单，为什么前端没有显示？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#%E5%9C%A8%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%B8%80%E4%B8%AA%E8%8F%9C%E5%8D%95-%E4%B8%BA%E4%BB%80%E4%B9%88%E5%89%8D%E7%AB%AF%E6%B2%A1%E6%9C%89%E6%98%BE%E7%A4%BA">#</a>在管理后台添加了一个菜单，为什么前端没有显示？</h3><p>只有在前端路由中配置了的菜单，在管理后台添加后才会显示，否则没有效果。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/2024-02-02_23:01:06_mall_permission_question_01-b6765324.png"></p>
<h3 id="前端路由中修改了菜单名称，为什么还是原来的名称？"><a href="#前端路由中修改了菜单名称，为什么还是原来的名称？" class="headerlink" title="#前端路由中修改了菜单名称，为什么还是原来的名称？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#%E5%89%8D%E7%AB%AF%E8%B7%AF%E7%94%B1%E4%B8%AD%E4%BF%AE%E6%94%B9%E4%BA%86%E8%8F%9C%E5%8D%95%E5%90%8D%E7%A7%B0-%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%98%E6%98%AF%E5%8E%9F%E6%9D%A5%E7%9A%84%E5%90%8D%E7%A7%B0">#</a>前端路由中修改了菜单名称，为什么还是原来的名称？</h3><p>菜单名称、图标、是否隐藏都是由管理后台配置的，当管理后台配置好后，前端修改是无效的。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/2024-02-02_23:01:06_mall_permission_question_02-56ab03c2.png"></p>
<h3 id="mall-swarm项目中的权限管理功能是如何实现的？"><a href="#mall-swarm项目中的权限管理功能是如何实现的？" class="headerlink" title="#mall-swarm项目中的权限管理功能是如何实现的？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall-swarm%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD%E6%98%AF%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%9A%84">#</a>mall-swarm项目中的权限管理功能是如何实现的？</h3><p>采用了基于Oauth2的的统一认证鉴权方式，通过认证服务进行统一认证，然后通过网关来统一校验认证和鉴权。具体可以参考：<a target="_blank" rel="noopener" href="https://www.macrozheng.com/cloud/gateway_oauth2.html">《微服务权限终极解决方案，Spring Cloud Gateway + Oauth2 实现统一认证和鉴权！》</a></p>
<h3 id="mall和mall-swarm项目中权限管理的实现有何不同？"><a href="#mall和mall-swarm项目中权限管理的实现有何不同？" class="headerlink" title="#mall和mall-swarm项目中权限管理的实现有何不同？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall%E5%92%8Cmall-swarm%E9%A1%B9%E7%9B%AE%E4%B8%AD%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E7%9A%84%E5%AE%9E%E7%8E%B0%E6%9C%89%E4%BD%95%E4%B8%8D%E5%90%8C">#</a>mall和mall-swarm项目中权限管理的实现有何不同？</h3><p>mall项目实现方式是Spring Security，相当于把安全功能封装成了一个工具包<code>mall-security</code>，然后其他模块通过依赖该工具包来实现权限管理，比如<code>mall-admin</code>模块。 mall-swarm项目实现方式是Oauth2+Gateway，采用的是统一的认证和鉴权，mall-swarm中的其他模块只需关注自己的相关业务，而无需依赖任何安全工具包，更加适合微服务架构。</p>
<h3 id="mall-swarm项目对接前端项目时为什么会提示你已经被登出？"><a href="#mall-swarm项目对接前端项目时为什么会提示你已经被登出？" class="headerlink" title="#mall-swarm项目对接前端项目时为什么会提示你已经被登出？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall-swarm%E9%A1%B9%E7%9B%AE%E5%AF%B9%E6%8E%A5%E5%89%8D%E7%AB%AF%E9%A1%B9%E7%9B%AE%E6%97%B6%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BC%9A%E6%8F%90%E7%A4%BA%E4%BD%A0%E5%B7%B2%E7%BB%8F%E8%A2%AB%E7%99%BB%E5%87%BA">#</a>mall-swarm项目对接前端项目时为什么会提示你已经被登出？</h3><p>一种情况是前端访问后端接口没有走网关，首先需要修改<code>mall-admin-web</code>项目的后端接口访问基础路径，修改文件为项目<code>config</code>目录下的<code>dev.env.js</code>，将<code>BASE_API</code>改为从网关访问<code>mall-admin</code>服务的路径。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#x27;use strict&#x27;</span><br><span class="line">const merge = require(&#x27;webpack-merge&#x27;)</span><br><span class="line">const prodEnv = require(&#x27;./prod.env&#x27;)</span><br><span class="line"></span><br><span class="line">module.exports = merge(prodEnv, &#123;</span><br><span class="line">  NODE_ENV: &#x27;&quot;development&quot;&#x27;,</span><br><span class="line">  BASE_API: &#x27;&quot;http://localhost:8201/mall-admin&quot;&#x27;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<p>另一种情况是没有更新到最新代码，需要更新到最新代码并导入最新版本的SQL。之前在<code>mall-gateway</code>项目中配置白名单的时候把<code>/mall-admin/admin/info</code>接口配置进去了，会导致无法登录的情况，需要去除掉，目前已经修复了。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">secure:</span><br><span class="line">  ignore:</span><br><span class="line">    urls: #配置白名单路径</span><br><span class="line">     - &quot;/mall-admin/admin/info&quot;</span><br></pre></td></tr></table></figure>

<p>还有一点需要注意的是由于<code>/mall-admin/admin/info</code>接口配置已经不在白名单中了，所以需要登录的用户需要配置该接口的相应资源，否则会无法登录。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/2024-02-02_23:01:06_mall_permission_question_03-4180e966.png"></p>
<h3 id="mall-swarm项目如何访问需要登录认证的接口？"><a href="#mall-swarm项目如何访问需要登录认证的接口？" class="headerlink" title="#mall-swarm项目如何访问需要登录认证的接口？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#mall-swarm%E9%A1%B9%E7%9B%AE%E5%A6%82%E4%BD%95%E8%AE%BF%E9%97%AE%E9%9C%80%E8%A6%81%E7%99%BB%E5%BD%95%E8%AE%A4%E8%AF%81%E7%9A%84%E6%8E%A5%E5%8F%A3">#</a>mall-swarm项目如何访问需要登录认证的接口？</h3><p>由于项目中存在两套不同的用户体系，后台用户和前台用户，认证中心对多用户体系也有所支持。如何访问需要登录的接口，先调用认证中心接口获取token，不同体系下的用户需要传入不同的<code>client_id</code>和<code>client_secret</code>，后台用户为<code>admin-app:123456</code>，前台用户为<code>portal-app:123456</code>。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/2024-02-02_23:01:06_swarm_deploy_windows_05-2123d535.png"></p>
<p>然后将token添加到请求头中，即可访问需要权限的接口了。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/2024-02-02_23:01:06_swarm_deploy_windows_06-1f8d5354.png"></p>
<p>当然对原来的登录接口也做了兼容处理，分别会从内部调用认证中心获取Token，依然可以使用。</p>
<ul>
<li><p>后台用户登录接口：<a target="_blank" rel="noopener" href="http://localhost:8201/mall-admin/admin/login">http://localhost:8201/mall-admin/admin/login</a></p>
</li>
<li><p>前台用户登录接口：<a target="_blank" rel="noopener" href="http://localhost:8201/mall-portal/sso/login">http://localhost:8201/mall-portal/sso/login</a></p>
</li>
</ul>
<h3 id="只想学习权限管理功能，有没有什么简单的项目可以学习下？"><a href="#只想学习权限管理功能，有没有什么简单的项目可以学习下？" class="headerlink" title="#只想学习权限管理功能，有没有什么简单的项目可以学习下？"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/technology/mall_permission_question.html#%E5%8F%AA%E6%83%B3%E5%AD%A6%E4%B9%A0%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD-%E6%9C%89%E6%B2%A1%E6%9C%89%E4%BB%80%E4%B9%88%E7%AE%80%E5%8D%95%E7%9A%84%E9%A1%B9%E7%9B%AE%E5%8F%AF%E4%BB%A5%E5%AD%A6%E4%B9%A0%E4%B8%8B">#</a>只想学习权限管理功能，有没有什么简单的项目可以学习下？</h3><p>可以直接学习下<code>mall-tiny</code>项目，<code>mall-tiny</code>是一款基于SpringBoot+MyBatis-Plus的快速开发脚手架，拥有完整的权限管理功能，可对接Vue前端，开箱即用。具体参考<a target="_blank" rel="noopener" href="https://www.macrozheng.com/roadmap/mall_tiny_start.html">《还在从零开始搭建项目？手撸了款快速开发脚手架！》</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io">十一星野</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io/2024/01/bdace4359249.html">https://ko25891wan.gitlab.io/2024/01/bdace4359249.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://ko25891wan.gitlab.io" target="_blank">小小程序员</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/01/2d0ff4da715e.html" title="给Swagger升级了新版本，没想到居然有这么多坑！"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">给Swagger升级了新版本，没想到居然有这么多坑！</div></div></a></div><div class="next-post pull-right"><a href="/2024/01/31ef856887ce.html" title="mall整合Elasticsearch实现商品搜索"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">mall整合Elasticsearch实现商品搜索</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">十一星野</div><div class="author-info__description">归途也还可爱</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Gitlab"><i class="fab fa-gitlab" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:ko25891wan@outlook.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%91%8D-%E7%9B%B8%E5%85%B3%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B"><span class="toc-number">1.</span> <span class="toc-text">👍 相关视频教程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#mall%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD%E6%98%AF%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%9A%84%EF%BC%9F"><span class="toc-number">1.1.</span> <span class="toc-text">mall项目中的权限管理功能是如何实现的？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ums-permission%E8%A1%A8%E8%BF%98%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B9%88%EF%BC%9F"><span class="toc-number">1.2.</span> <span class="toc-text">ums_permission表还在使用么？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mall%E9%A1%B9%E7%9B%AE%E5%8D%87%E7%BA%A7%E4%BB%A3%E7%A0%81%E5%90%8Eums-resource%E8%A1%A8%E6%89%BE%E4%B8%8D%E5%88%B0%EF%BC%9F"><span class="toc-number">1.3.</span> <span class="toc-text">mall项目升级代码后ums_resource表找不到？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8F%AA%E5%AE%9E%E7%8E%B0%E4%BA%86%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E7%9A%84%E6%9D%83%E9%99%90%EF%BC%8C%E7%A7%BB%E5%8A%A8%E7%AB%AF%E6%9D%83%E9%99%90%E5%A6%82%E4%BD%95%E5%A4%84%E7%90%86%E7%9A%84%EF%BC%9F"><span class="toc-number">1.4.</span> <span class="toc-text">只实现了管理后台的权限，移动端权限如何处理的？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%B8%80%E4%B8%AA%E8%8F%9C%E5%8D%95%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E5%89%8D%E7%AB%AF%E6%B2%A1%E6%9C%89%E6%98%BE%E7%A4%BA%EF%BC%9F"><span class="toc-number">1.5.</span> <span class="toc-text">在管理后台添加了一个菜单，为什么前端没有显示？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF%E8%B7%AF%E7%94%B1%E4%B8%AD%E4%BF%AE%E6%94%B9%E4%BA%86%E8%8F%9C%E5%8D%95%E5%90%8D%E7%A7%B0%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%98%E6%98%AF%E5%8E%9F%E6%9D%A5%E7%9A%84%E5%90%8D%E7%A7%B0%EF%BC%9F"><span class="toc-number">1.6.</span> <span class="toc-text">前端路由中修改了菜单名称，为什么还是原来的名称？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mall-swarm%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD%E6%98%AF%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%9A%84%EF%BC%9F"><span class="toc-number">1.7.</span> <span class="toc-text">mall-swarm项目中的权限管理功能是如何实现的？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mall%E5%92%8Cmall-swarm%E9%A1%B9%E7%9B%AE%E4%B8%AD%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E7%9A%84%E5%AE%9E%E7%8E%B0%E6%9C%89%E4%BD%95%E4%B8%8D%E5%90%8C%EF%BC%9F"><span class="toc-number">1.8.</span> <span class="toc-text">mall和mall-swarm项目中权限管理的实现有何不同？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mall-swarm%E9%A1%B9%E7%9B%AE%E5%AF%B9%E6%8E%A5%E5%89%8D%E7%AB%AF%E9%A1%B9%E7%9B%AE%E6%97%B6%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BC%9A%E6%8F%90%E7%A4%BA%E4%BD%A0%E5%B7%B2%E7%BB%8F%E8%A2%AB%E7%99%BB%E5%87%BA%EF%BC%9F"><span class="toc-number">1.9.</span> <span class="toc-text">mall-swarm项目对接前端项目时为什么会提示你已经被登出？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mall-swarm%E9%A1%B9%E7%9B%AE%E5%A6%82%E4%BD%95%E8%AE%BF%E9%97%AE%E9%9C%80%E8%A6%81%E7%99%BB%E5%BD%95%E8%AE%A4%E8%AF%81%E7%9A%84%E6%8E%A5%E5%8F%A3%EF%BC%9F"><span class="toc-number">1.10.</span> <span class="toc-text">mall-swarm项目如何访问需要登录认证的接口？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8F%AA%E6%83%B3%E5%AD%A6%E4%B9%A0%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD%EF%BC%8C%E6%9C%89%E6%B2%A1%E6%9C%89%E4%BB%80%E4%B9%88%E7%AE%80%E5%8D%95%E7%9A%84%E9%A1%B9%E7%9B%AE%E5%8F%AF%E4%BB%A5%E5%AD%A6%E4%B9%A0%E4%B8%8B%EF%BC%9F"><span class="toc-number">1.11.</span> <span class="toc-text">只想学习权限管理功能，有没有什么简单的项目可以学习下？</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/c60470b9a892.html" title="Java集合使用注意事项总结">Java集合使用注意事项总结</a><time datetime="2024-02-03T04:58:22.000Z" title="发表于 2024-02-03 12:58:22">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/81fb7a201f29.html" title="无题">无题</a><time datetime="2024-02-03T03:15:31.812Z" title="发表于 2024-02-03 11:15:31">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/5737c1ec69a9.html" title="Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)">Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)</a><time datetime="2024-01-31T06:56:16.000Z" title="发表于 2024-01-31 14:56:16">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/f510db7d2f19.html" title="Spring常见面试题总结">Spring常见面试题总结</a><time datetime="2024-01-31T06:55:58.000Z" title="发表于 2024-01-31 14:55:58">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/9be065e9f288.html" title="redis 面试">redis 面试</a><time datetime="2024-01-31T06:55:55.000Z" title="发表于 2024-01-31 14:55:55">2024-01-31</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 十一星野</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.staticfile.org/instant.page/5.2.0/instantpage.min.js" type="module"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>